package com.java.a05TCPDemo1;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        //TCP协议, 发送数据

        //1.创建Socket对象
        // 细节：在创建对象的同时会连接服务器
        //  如果连接不上, 代码会报错
        Socket socket = new Socket("10.40.252.10", 10001);

        //从连接通道之中获取输出流
        OutputStream os = socket.getOutputStream();

        //写出数据
        byte[] bytes = "你好呀~~".getBytes();
        os.write(bytes);

        //释放资源
        socket.close();
    }
}
